package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC482 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String licenseKeyFormatting(String S, int K) {
            if (K <= 0) {
                return "";
            }

            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) != '-') {
                    builder.append(S.charAt(i));
                }
            }

            for (int i = builder.length() - K; i > 0; i -= K) {
                builder.insert(i, '-');
            }

            return builder.toString().toUpperCase();
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC482 an = new LC482();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
